package com.kpmg.datalake.schedule.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.kpmg.datalake.schedule.model.ScheduleJob;
import com.kpmg.datalake.schedule.service.ScheduleExecuteService;
import org.springframework.stereotype.Service;

import java.util.Random;

/**
 * @author Alex.zhao [alex.zhao@kpmg.com]
 * @since Created on azhao6 on 2018-08-09 22:39:53
 */
@Service
public class TestJobImpl implements ScheduleExecuteService {
    @Override
    public void execute(ScheduleJob scheduleJob) {
        Random random = new Random();
        int sleepTime = random.nextInt(10) * 1000;
        try {

            Thread.sleep(sleepTime);

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        if (sleepTime > 5000) {
            sleepTime = 1 / 0;
        }
        System.out.println(JSONObject.toJSON(scheduleJob));
    }


}
